﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace RCREEE.Library.Entities
{
    public class ApprovedIncentives
    {
        #region private variable

        private int _ApprovedIncentiveId;
        private int _IncentiveId;
        private int _CountryId;
        private int _LanguageCode;
        private int _Percentage;
        private int _ItemId;
        private string _Ceiling;
        private string _Name;
        private int Roweffect ;
        private DataTable ApprovedIncentive=new DataTable();
        #endregion

        #region public properties
  
        public int ItemId
        {
        get { return _ItemId; }
        set { _ItemId = value; }
        }
        public int ApprovedIncentiveId
        {
            get { return _ApprovedIncentiveId; }
            set { _ApprovedIncentiveId = value; }
        }

        public int IncentiveId
        {
            get { return _IncentiveId; }
            set { _IncentiveId = value; }
        }
        public int CountryId
        {
            get { return _CountryId; }
            set { _CountryId = value; }
        }
        public int LanguageCode
        {
            get { return _LanguageCode; }
            set { _LanguageCode = value; }
        }
        public int Percentage
        {
            get { return _Percentage; }
            set { _Percentage = value; }
        }

        public string Ceiling
        {
            get { return _Ceiling; }
            set { _Ceiling = value; }
        }

        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }
        #endregion

        #region Constractor
        public ApprovedIncentives() { }
        #endregion

        #region private Methods
        
        #endregion

        #region Public Methods
        #region Get

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public DataTable GetApprovedIncentives(int CountryId, int LanguageCode)
        {
            try
            {
                return DataManager.GetApprovedIncentives(CountryId, LanguageCode);
            }
            catch (Exception) { return null; }
        }


        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public DataTable GetOneApprovedIncentives(int CountryId, int LanguageCode, int ItemId)
        {
            try
            {
                return DataManager.GetOneApprovedIncentives(CountryId, LanguageCode, ItemId);
            }
            catch (Exception) { return null; }
        }

       
        public List<ApprovedIncentives> WebGetApprovedIncentives(int CountryId, int LanguageCode)
        {
            try
            {
                List<ApprovedIncentives> ApprovedIncentives = new List<ApprovedIncentives>();
                ApprovedIncentive = DataManager.GetApprovedIncentives(CountryId, LanguageCode);
                for (int i = 0; i < ApprovedIncentive.Rows.Count; i++)
                {
                    ApprovedIncentives[i].ApprovedIncentiveId = Convert.ToInt32(ApprovedIncentive.Rows[i]["ApprovedIncentiveId"]);
                    ApprovedIncentives[i].CountryId = Convert.ToInt32(ApprovedIncentive.Rows[i]["CountryId"]);
                    ApprovedIncentives[i].IncentiveId = Convert.ToInt32(ApprovedIncentive.Rows[i]["IncentiveId"]);
                    ApprovedIncentives[i].ItemId = Convert.ToInt32(ApprovedIncentive.Rows[i]["ItemId"]);
                    ApprovedIncentives[i].LanguageCode = Convert.ToInt32(ApprovedIncentive.Rows[i]["LanguageCode"]);
                    ApprovedIncentives[i].Percentage = Convert.ToInt32(ApprovedIncentive.Rows[i]["Percentage"]);
                    ApprovedIncentives[i].Ceiling = Convert.ToString(ApprovedIncentive.Rows[i]["Ceiling"]);
                    ApprovedIncentives[i].Name = Convert.ToString(ApprovedIncentive.Rows[i]["Name"]);

                }

                return ApprovedIncentives;
            }
            catch (Exception) { return null; }
        }
        public ApprovedIncentives WebGetOneApprovedIncentives(int CountryId, int LanguageCode, int ItemId)
        {
            try
            {   ApprovedIncentives ApprovedIncentives=new Entities.ApprovedIncentives();
                ApprovedIncentive= DataManager.GetOneApprovedIncentives(CountryId, LanguageCode, ItemId);
                 ApprovedIncentives.ApprovedIncentiveId = Convert.ToInt32(ApprovedIncentive.Rows[0]["ApprovedIncentiveId"]);
                    ApprovedIncentives.CountryId = Convert.ToInt32(ApprovedIncentive.Rows[0]["CountryId"]);
                    ApprovedIncentives.IncentiveId = Convert.ToInt32(ApprovedIncentive.Rows[0]["IncentiveId"]);
                    ApprovedIncentives.ItemId = Convert.ToInt32(ApprovedIncentive.Rows[0]["ItemId"]);
                    ApprovedIncentives.LanguageCode = Convert.ToInt32(ApprovedIncentive.Rows[0]["LanguageCode"]);
                    ApprovedIncentives.Percentage = Convert.ToInt32(ApprovedIncentive.Rows[0]["Percentage"]);
                    ApprovedIncentives.Ceiling = Convert.ToString(ApprovedIncentive.Rows[0]["Ceiling"]);

                    return ApprovedIncentives;
            }
            catch (Exception) { return null; }
        }

        #endregion

        public bool UpdateApprovedIncentives(List<ApprovedIncentives> Approved)
        {
            try
            {
                
                    Roweffect=DataManager.UpdateApprovedIncentives(Approved);
                    return Roweffect == 1;
            }
            catch (Exception) { return Roweffect == 0; }
        }
       //// public bool InsertApprovedIncentives(ApprovedIncentives Approved)
       // {
       //     try
       //     {
       //         Roweffect = DataManager.InsertApprovedIncentives(Approved);
       //        return Roweffect == 1;
       //     }
       //     catch (Exception) { return Roweffect == 0; }
       // }
       // public bool DeleteApprovedIncentives(ApprovedIncentives Approved)
       // {
       //     try
       //     {
       //         Roweffect = DataManager.DeleteApprovedIncentives(Approved);
       //          return Roweffect == 1;
       //     }
       //     catch (Exception) { return Roweffect == 0; }
       // }
        #endregion

        #region overrides
        public override string ToString()
        {
            return ApprovedIncentiveId.ToString();
        }
        #endregion


    }
}
